//
//  HYFtabBarVC.m
//  hyf-BaiSi
//
//  Created by Bill on 14/6/16.
//  Copyright © 2016年 hyf. All rights reserved.
//

#import "HYFtabBarVC.h"
#import "HYFEssenceViewVc.h"
#import "HYFFriendTrendViewVC.h"
#import "HYFMeViewVC.h"
#import "HYFNewViewVC.h"
#import "HYFPublicViewVC.h"
#import "UIImage+HYFimage.h"
#import "HYFNaViGaTionController.h"

@interface HYFtabBarVC ()



@end





@implementation HYFtabBarVC


-(void)viewDidLoad{
    [super viewDidLoad];
    
    //本控制器TABBAR控制器添加各子控制器
    [self addAllChildVC];

    //给本控制器下各个子控制器添加按钮
    [self setAllButton];
    
    [self setMiddleButton];
}

//设置文字不给渲染
+(void)load{
    
    UITabBarItem *item=[UITabBarItem appearance];
    //设置文字颜色
    NSMutableDictionary *arr=[NSMutableDictionary dictionary];
    arr[NSForegroundColorAttributeName]=[UIColor blackColor];
    [item setTitleTextAttributes:arr forState:UIControlStateSelected];
    
    //设置文字大小
    NSMutableDictionary *arr2=[NSMutableDictionary dictionary];
    arr2[NSFontAttributeName]=[UIFont systemFontOfSize:14];
    [item setTitleTextAttributes:arr2 forState:UIControlStateNormal];
    
}


//给中间添加按钮
-(void)setMiddleButton{
    
    UIButton *Mbutton=[UIButton buttonWithType:UIButtonTypeCustom];
    [Mbutton setImage:[UIImage imageNamed:@"tabBar_publish_icon"] forState:UIControlStateNormal];
    [Mbutton setImage:[UIImage imageNamed:@"tabBar_publish_click_icon"] forState:UIControlStateHighlighted];
    
    [Mbutton sizeToFit];
    Mbutton.center=CGPointMake(xmgScreenW *0.5,self.tabBar.xmg_height *0.5);
    [self.tabBar addSubview:Mbutton];


}


-(void)setAllButton{
    
    // 精华
    UIViewController *vc = self.childViewControllers[0];
    vc.tabBarItem.title = @"精华";
    vc.tabBarItem.image = [UIImage imageNamed:@"tabBar_essence_icon"];
    vc.tabBarItem.selectedImage=[UIImage imageOriginalWithImageName:@"tabBar_essence_click_icon"];
    
    
    // 新帖
    UIViewController *vc1 = self.childViewControllers[1];
    vc1.tabBarItem.title = @"新帖";
    vc1.tabBarItem.image = [UIImage imageNamed:@"tabBar_new_icon"];
    vc1.tabBarItem.selectedImage=[UIImage imageOriginalWithImageName:@"tabBar_new_click_icon"];
    
    
    // 发布
    UIViewController *vc2 = self.childViewControllers[2];
    vc2.tabBarItem.image = [UIImage imageNamed:@"tabBar_publish_icon"];
    vc2.tabBarItem.selectedImage=[UIImage imageOriginalWithImageName:@"tabBar_publish_click_icon"];
    vc2.tabBarItem.enabled=NO;
    
    // 关注
    UIViewController *vc3 = self.childViewControllers[3];
    vc3.tabBarItem.title = @"关注";
    vc3.tabBarItem.image = [UIImage imageNamed:@"tabBar_friendTrends_icon"];
    vc3.tabBarItem.selectedImage=[UIImage imageOriginalWithImageName:@"tabBar_friendTrends_click_icon"];
    
    // 我
    UIViewController *vc4 = self.childViewControllers[4];
    vc4.tabBarItem.title = @"我";
    vc4.tabBarItem.image = [UIImage imageNamed:@"tabBar_me_icon"];
    vc4.tabBarItem.selectedImage=[UIImage imageOriginalWithImageName:@"tabBar_me_click_icon"];
    

}


//self添加所有的子控制器
-(void)addAllChildVC{

    //精华
    HYFEssenceViewVc *essenceVC=[[HYFEssenceViewVc alloc]init];
    HYFNaViGaTionController *vc1=[[HYFNaViGaTionController alloc]initWithRootViewController:essenceVC];
    [self addChildViewController:vc1];
    
    //新帖
    HYFNewViewVC *newVC=[[HYFNewViewVC alloc]init];
    HYFNaViGaTionController *vc4=[[HYFNaViGaTionController alloc]initWithRootViewController:newVC];
    [self addChildViewController:vc4];
    
    //发布
    HYFPublicViewVC *punlicVC=[[HYFPublicViewVC alloc]init];
    [self addChildViewController:punlicVC];
    
    //关注
    HYFFriendTrendViewVC *friendtrendVC=[[HYFFriendTrendViewVC alloc]init];
    HYFNaViGaTionController *vc3=[[HYFNaViGaTionController alloc]initWithRootViewController:friendtrendVC];
    [self addChildViewController:vc3];
    
    //我
    HYFMeViewVC *meVC=[[HYFMeViewVC alloc]init];
    HYFNaViGaTionController *vc2=[[HYFNaViGaTionController alloc]initWithRootViewController:meVC];
    [self addChildViewController:vc2];
    
    
}



@end
